package edu.xust.web.controller;

import edu.xust.config.*;
import edu.xust.dto.BaseDto;
import edu.xust.dto.MessageEnum;
import edu.xust.entity.Student;
import edu.xust.service.StudentService;

/**
 * 学生类的控制器 门卫 对url的响应处理
 */
@Controller("/studentController")
public class StudentController {
    @Resource
    StudentService studentService;
    /**
     * 查询全部学生 示例 无参数方法
     * @return
     */
    @RequestMapping("/getStudents")
    @ResponseBody
    public BaseDto getAllStudents() throws Exception {
        return  studentService.getAllStudents();
    }

    /**
     * 根据主键查询 示范简单参数
     * @param id
     * @return
     */
    @RequestMapping("/getStudentById/{id}")
    public BaseDto getStudentById(String id){
        System.out.println(id);
        BaseDto dto = new BaseDto(MessageEnum.GETSTUDENTBYIDSUCCESS);
        return  dto;
    }

    /**
     * 添加
     * @param student
     * @return
     */
    @RequestMapping("/addStudent")
    @ResponseBody
    public BaseDto addStudent(@RequestBody Student student){
        System.out.println(student);
        BaseDto dto = new BaseDto(MessageEnum.ADDSTUDENTSUCCESS,student);
        return  dto;
    }

    @RequestMapping("/editStudent")
    @ResponseBody
    public BaseDto editStudent(@RequestBody Student student){
        System.out.println(student);
        BaseDto dto = new BaseDto(MessageEnum.ADDSTUDENTSUCCESS,student);
        return  dto;
    }
    @RequestMapping("/cancelCourse")
    public BaseDto cancelCourse(String courseJson){
        BaseDto dto = new BaseDto(MessageEnum.GETSTUDENTBYIDSUCCESS);
        return  dto;
    }
}

